<template>
  <el-card>
    <el-row
      ><el-col :span="12"><pic1 cate="收入"></pic1></el-col>
      <el-col :span="12"> <pic2 cate="支出"></pic2></el-col
    ></el-row>
    <el-row style="margin-top: 7px;text-align: center;"><strong>支出最高的前三项明细</strong></el-row>
    <el-row style="margin-top: 6px">
      <el-table
        stripe
        :data="list"
        element-loading-text="Loading..."
        border
        fit
        highlight-current-row
      >
        <el-table-column align="center" label="序号" width="100">
          <template slot-scope="scope">
            {{ scope.row.id }}
          </template>
        </el-table-column>
        <el-table-column align="center" label="商品描述" width="190">
          <template slot-scope="scope">
            {{ scope.row.description }}
          </template>
        </el-table-column>
        <el-table-column label="￥价格" width="100" align="center">
          <template slot-scope="scope">
            {{ scope.row.price }}
          </template>
        </el-table-column>
        <el-table-column label="类别" align="center" width="170">
          <template slot-scope="scope">
            <el-tag effect="dark">{{ scope.row.category }}</el-tag>
          </template>
        </el-table-column>
        <!-- 默认是当前时间 -->
        <el-table-column  prop="time" label="支出时间" align="center">
          <template slot-scope="scope">
            {{ scope.row.time | formatDate() }}
          </template>
        </el-table-column>
      </el-table>
    </el-row>
  </el-card>
</template>

<script>
// import pic from "./draw/pic.vue";
const pic1 = () => import("./draw/pic.vue");
const pic2 = () => import("./draw/pic.vue");
export default {
  name: "Analysis",
  data() {
    return {
      list: [],
    };
  },
  mounted() {
    this.getList();
  },
  filters: {
      formatDate: function (value) {
        var dt = new Date(value);
        console.log(dt)
        let year = dt.getFullYear();
        let month = dt.getMonth() + 1;
        let date = dt.getDate();
        return `${year}年${month}月${date}日`;
      },
    },
  methods: {
    async getList() {
      let re = await this.$API.table.getThreeList();
      if (re.status == 200) {
        this.list = re.data;
      }
    },
  },
  components: {
    pic1,
    pic2,
  },
};
</script>

<style scoped>
</style>